package com.lwc.config;

import feign.Request;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import feign.Logger;
import org.springframework.http.client.support.BasicAuthenticationInterceptor;

import java.util.concurrent.TimeUnit;

@Configuration
public class FeignConfig {

@Bean
    public Logger.Level level(){

        return  Logger.Level.BASIC;
    }

    /**
     * 拦截请求
     * @return
     */
    /*@Bean
public BasicAuthenticationInterceptor basicAuthenticationInterceptor(){
    //用户名和密码 是当前服务（服务消费者）   要访问服务提供者（sc-goods） 账号和密码
    return  new BasicAuthenticationInterceptor("admin","1357");
}*/

    /**
     * 每次请求传递请求头
     * @return
     */
    @Bean
    public  TokenRequestInterceptor tokenRequestInterceptor(){
        return  new TokenRequestInterceptor();
    }

@Bean
    public Request.Options options(){
return  new Request.Options(10000, TimeUnit.MILLISECONDS,10000,TimeUnit.MILLISECONDS,true);
    }

}
